package com.cskaoyan.controller.admin.systemcontroller;

import com.cskaoyan.bean.mallbean.Storage;
import com.cskaoyan.service.systemservice.StorageService;
import com.cskaoyan.vo.BaseRespVo;
import com.cskaoyan.vo.systemvo.StorageListVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StorageController {
    @Autowired
    StorageService storageService;

    @RequiresPermissions("admin:storage:list")
    @RequestMapping("admin/storage/list")
    public BaseRespVo list(Integer page,Integer limit,String key,String name,String sort,String order){
        StorageListVo storageListVo = storageService.list(page,limit,key,name,sort,order);
        return BaseRespVo.ok(storageListVo);
    }

    @RequiresPermissions("admin:storage:update")
    @RequestMapping("admin/storage/update")
    public BaseRespVo update(@RequestBody Storage storage){
        Storage storage1 = storageService.update(storage);
        return BaseRespVo.ok(storage1);
    }

    @RequiresPermissions("admin:storage:delete")
    @RequestMapping("admin/storage/delete")
    public BaseRespVo delete(@RequestBody Storage storage){
        storageService.delete(storage);
        return BaseRespVo.ok();
    }



}
